import 'package:flutter/material.dart';
import 'package:flutter_study/widgets/public/themes/index.dart';
import 'package:rc_widget/rc_widget.dart';

class AppFormLabel extends StatelessWidget {
  final String? label;
  final Widget? left;
  final Widget? right;

  const AppFormLabel({super.key, this.label, this.left, this.right});

  @override
  Widget build(BuildContext context) {
    return Row(
      children: [
        _buildLeftLine(),
        _buildLabel(),
        if (right != null) right!,
      ],
    );
  }

  Widget _buildLeftLine() {
    return Container(
      width: 6.w,
      height: 24.h,
      margin: EdgeInsets.only(right: 8.w),
      decoration: BoxDecoration(
          color: AppThemes.of().colors.background3,
          borderRadius: BorderRadius.circular((6.sp))),
    );
  }

  Widget _buildLabel() {
    return Expanded(
      child: left ??
          Text(
            label ?? '',
            style: AppThemes.of().w700Text128,
            overflow: TextOverflow.ellipsis,
            maxLines: 1,
          ),
    );
  }
}
